package com.hspedu.socket;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Socket;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/3/2
 * @time 16:15
 */
public class SocketTCP02Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket(InetAddress.getLocalHost(), 8888);

        InputStream inputStream = socket.getInputStream();
        byte[] buffer = new byte[1024];
        int readLen = 0;

        while((readLen = inputStream.read(buffer)) != -1){
            System.out.println(new String(buffer,0,readLen));
        }

        inputStream.close();
        socket.close();
    }
}
